package visitor.example;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cheng:
 * @date 2019/4/27 14:07
 */
public class ObjectStructure {

    List<Person> elements = new ArrayList<>();

    public void attach(Person element){
        elements.add(element);
    }

    public void detach(Person element){
        elements.remove(element);
    }

    public void accept(Action visitor){
        for (Person element: elements) {
            element.accept(visitor);
        }
    }
}
